package com.mathdroid.exceptionhandling;

import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;

/**
 * This class is used to access the clipboard of the operation system.
 */
public class DroidClipboard implements ClipboardOwner {

	/**
	 * Proxy object to the system clipboard.
	 */
	private final Clipboard c = 
		Toolkit.getDefaultToolkit().getSystemClipboard();
	
	/**
	 * Listens to change in ownership, but not needed. Not implemented.
	 * @param clipboard Not implemented.
	 * @param t Not implemented.
	 */
	@Override
	public final void lostOwnership(
			final Clipboard clipboard, final Transferable t) { }
	
	/**
	 * Copies a String to the clipboard.
	 * @param s The String to add.
	 */
	public final void copy(final String s) {
		this.c.setContents(new StringSelection(s), this);
	}
}
